package org.support.small.mallms.utils;

public class RequestContextUtils {
    private final static ThreadLocal<Long> CURRENT_LOGIN_ID_POOL = new ThreadLocal<>();
    private final static ThreadLocal<String> CURRENT_LOGIN_NAME_POOL = new ThreadLocal<>();

    public static void login(Long adminId, String username) {
        CURRENT_LOGIN_ID_POOL.set(adminId);
        CURRENT_LOGIN_NAME_POOL.set(username);
    }

    public static Long getAdminId() {
        return CURRENT_LOGIN_ID_POOL.get();
    }

    public static String getUsername() {
        return CURRENT_LOGIN_NAME_POOL.get();
    }

    public static void clear() {
        CURRENT_LOGIN_ID_POOL.remove();
        CURRENT_LOGIN_NAME_POOL.remove();
    }
}
